//
//  MyViewController.m
//  zhixinApp
//
//  Created by zhiguanzhl on 2017/11/11.
//  Copyright © 2017年 zhiguanzhl. All rights reserved.
//

#import "MyViewController.h"
#import "SBMyWebViewController.h"
#import "LoginViewController.h"
#import "ArrowsCell.h"

@interface MyViewController ()
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UIButton *imgBtn;
@property (weak, nonatomic) IBOutlet UILabel *companyName;
@property (nonatomic,strong)NSArray *arr;
@property (weak, nonatomic) IBOutlet UITableView *tableView;



@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ViewRadius(self.imgBtn, 10);
    
    self.tableView.tableFooterView = [[UIView alloc] init];
//    [self.tableView reloadData];
   
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSArray *arr = [DataCenter shareInstence].companyList;
    UserInfoModel *model = [arr lastObject];
    self.companyName.text = model.name;
    self.name.text = [DataCenter shareInstence].name;
    self.navigationController.navigationBarHidden = YES;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  56;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ArrowsCell *arrowCell = [ArrowsCell cellWithTableView:tableView];
    if (indexPath.row == 0) {
        arrowCell.dic = @{@"账户安全":@"zhan_icon"};
    }else if (indexPath.row == 1) {
        arrowCell.dic = @{@"关于智信":@"about"};
    }else{
        arrowCell.dic = @{@"退出登录":@"out_icon"};
    }
//    arrowCell.dic = self.arr[indexPath.row];
    return arrowCell;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 2) {
        //清楚缓存
        [[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"userToken"];
        
        //用户信息
        [[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"userInfoModal"];
        
        //所有用户
        [[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"numberArr"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        //    passWord
        [[NSUserDefaults standardUserDefaults] setValue:@"" forKey:@"passWord"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
        //退出环信
        [[EMClient sharedClient] logout:YES completion:nil];
    
        self.tabBarController.selectedIndex = 2;
        
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self presentViewController:loginVc animated:YES completion:nil];
    }else if (indexPath.row == 1){
        
        //取得本地程序的版本号
        NSDictionary *localDic =[[NSBundle mainBundle] infoDictionary];
        NSString *localVersion =[localDic objectForKey:@"CFBundleShortVersionString"];
        NSString *version = [NSString stringWithFormat:@"%@%@",@"本地程序版本号是",localVersion];
        iToast *itost = [[iToast alloc] initWithText:version];
        [itost show];
        
    }else{
        iToast *itost = [[iToast alloc] initWithText:@"小智正在加速为您开发，敬请期待"];
        [itost show];
    }
}

- (NSArray *)arr{
    if (_arr) {
//        _arr = [[NSArray alloc] init];
        UIImage *image1 = [UIImage imageNamed:@"open_icon"];
        UIImage *image2 = [UIImage imageNamed:@"open_icon"];
        UIImage *image3 = [UIImage imageNamed:@"open_icon"];
        NSArray *arr1 = @[
                          @{@"账户安全":image1},
                          @{@"关于智信":image2},
                          @{@"退出登录":image3}];
        _arr = [[NSArray alloc] initWithArray:arr1];
        
    }
    return _arr;
}

@end
